#include <stdio.h>

int main()
{
    FILE *fp;

    char *cmd = "ls";
    char res[1024] = {0};

    fp = popen(cmd, "r");
    if (fp == NULL) {
        printf("popen error!\n");
        return -1;
    }

    int ret = fread(res, sizeof(char), sizeof(res), fp);
    if (ret > 0) {
        printf("OUTPUT:\n");
        printf("%s\n", res);
    }
}

